import org.junit.Test;

import java.math.BigDecimal;

public class BuyFruit {


    // 苹果单价
    public BigDecimal appleUnitPrice = new BigDecimal("8");
    // 草莓单价
    public BigDecimal strawberriesUnitPrice = new BigDecimal("13");
    // 芒果单价
    public BigDecimal mangoUnitPrice = new BigDecimal("20");
    // 草莓折扣
    public BigDecimal strawberriesDiscount = new BigDecimal("0.8");

    // 顾客A
    @Test
    public void CustomerA() {
        BigDecimal appleCount = new BigDecimal("2");
        BigDecimal strawberriesCount = new BigDecimal("1");
        BigDecimal TotalPrice = CustomerTotalPriceA(appleCount, strawberriesCount);
        System.out.println(TotalPrice);
    }

    public BigDecimal CustomerTotalPriceA(BigDecimal appleCount, BigDecimal strawberriesCount) {
        BigDecimal price = appleUnitPrice.multiply(appleCount).add(strawberriesUnitPrice.multiply(strawberriesCount));
        return price;
    }

    // 顾客B
    @Test
    public void CustomerB() {
        BigDecimal appleCount = new BigDecimal("2");
        BigDecimal strawberriesCount = new BigDecimal("1");
        BigDecimal mangoCount = new BigDecimal("3");
        BigDecimal TotalPrice = CustomerTotalPriceB(appleCount, strawberriesCount, mangoCount);
        System.out.println(TotalPrice);
    }

    public BigDecimal CustomerTotalPriceB(BigDecimal appleCount, BigDecimal strawberriesCount, BigDecimal mangoCount) {
        BigDecimal price = appleUnitPrice.multiply(appleCount).add(strawberriesUnitPrice.multiply(strawberriesCount)).add(mangoUnitPrice.multiply(mangoCount));
        return price;
    }

    // 顾客C
    @Test
    public void CustomerC() {
        BigDecimal appleCount = new BigDecimal("2");
        BigDecimal strawberriesCount = new BigDecimal("1");
        BigDecimal mangoCount = new BigDecimal("3");
        BigDecimal TotalPrice = CustomerTotalPriceC(appleCount, strawberriesCount, mangoCount);
        System.out.println(TotalPrice);
    }

    public BigDecimal CustomerTotalPriceC(BigDecimal appleCount, BigDecimal strawberriesCount, BigDecimal mangoCount) {
        BigDecimal price = appleUnitPrice.multiply(appleCount).add(strawberriesUnitPrice.multiply(strawberriesCount).multiply(strawberriesDiscount)).add(mangoUnitPrice.multiply(mangoCount));
        return price;
    }

    // 顾客D
    @Test
    public void CustomerD() {
        BigDecimal appleCount = new BigDecimal("0");
        BigDecimal strawberriesCount = new BigDecimal("0");
        BigDecimal mangoCount = new BigDecimal("5");
        BigDecimal TotalPrice = CustomerTotalPriceD(appleCount, strawberriesCount, mangoCount);
        System.out.println(TotalPrice);
    }

    public BigDecimal CustomerTotalPriceD(BigDecimal appleCount, BigDecimal strawberriesCount, BigDecimal mangoCount) {
        BigDecimal price = appleUnitPrice.multiply(appleCount).add(strawberriesUnitPrice.multiply(strawberriesCount)).add(mangoUnitPrice.multiply(mangoCount));
        if (price.compareTo(new BigDecimal("100")) >= 0) {
            price = price.subtract(new BigDecimal("10"));
        }
        return price;
    }

}
